import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

public class listUsers extends HttpServlet {

	public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		String msg = getUserList();
		out.println("<html>");
		out.println("<head>");
		out.println("<title>List of Users</title>");
		out.println("</head>");
		out.println("<body bgcolor=#A3D49C>");
		out.println("<img src='http://i56.tinypic.com/fa61kk.png'>");
		out.println("<br />");
		out.println("<br />");
		out.println("<br />");
		out.println("<br />");
		out.println(msg);
		out.println("</body>");
		out.println("</html>");
	}
	
	public void doPost (HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException {
		doGet(request, response);
	}
	
	private String getUserList(){
		String msg = "";
		ArrayList<User> users = UserIO.getUsers();
		for (User u : users){
			msg += u.name + ": ";
			msg += u.username + "<br />";
		}
		return msg;
	}
}











